package net.linku.model;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public abstract class BaseDTO<T extends Model<?>> extends Model<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableField(value = "created_by", fill = FieldFill.INSERT)
    private Long createdBy;

    @TableField(value = "last_updated_by", fill = FieldFill.INSERT_UPDATE)
    private Long lastUpdatedBy;

    @TableField(value = "creation_date", fill = FieldFill.INSERT)
    private Date creationDate;

    @TableField(value = "last_update_date", fill = FieldFill.INSERT_UPDATE)
    private Date lastUpdateDate;

    @TableLogic(value = "0", delval = "1")
    @TableField(value = "deleted_flag", fill = FieldFill.INSERT)
    private Integer deletedFlag = 0;

    @TableField(value = "enabled_flag", fill = FieldFill.INSERT)
    private Integer enabledFlag = 1;

    @Version
    @TableField(value = "object_version_number", fill = FieldFill.INSERT)
    private Long objectVersionNumber;

    public Integer getDeletedFlag() {
        return deletedFlag;
    }

    public Integer getEnabledFlag() {
        return enabledFlag;
    }
}
